package com.gsk.europepharma.salesReport.struts.actions;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONObject;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.gsk.europepharma.salesReport.utils.Legende;

public class DataLegende extends Action {
	
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		HttpSession sessionObject = request.getSession();
		
		Legende legendeRegion = (Legende) sessionObject.getAttribute("legendeRegion");
		Legende legendeSecteur = (Legende) sessionObject.getAttribute("legendeSecteur");
		
		HashMap hm = new HashMap();
		
		hm.put("legendeRegion", legendeRegion);
        hm.put("legendeSecteur", legendeSecteur);
        
        JSONObject json = JSONObject.fromObject(hm);

        response.addHeader("Content-Type", "application/json");
        response.getOutputStream().write(json.toString().getBytes("UTF-8"));
        response.getOutputStream().flush();

		return null;
		
	}

}
